home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
qbasicpg.zip
/
COINS2.BAS
< prev
next >
Wrap
BASIC Source File
|
1989-08-31
|
2KB
|
62 lines
' COINS2.BAS
' This program uses the WRITE# statement to send coin-collection
' information to a sequential file and INPUT# to display it.
' open file in APPEND mode so that previous contents won't be overwritten
OPEN "COINS.TXT" FOR APPEND AS #1 ' open file in current drive/dir
CLS
PRINT "This program stores coin-collection information on disk in a"
PRINT "file named COINS.TXT. Enter coin data and type END to quit."
PRINT
DO WHILE (country$ <> "END") ' until the user types END...
' get coin-collection info from user and write it to the open file
INPUT "What country is the coin from? ", country$
IF (country$ <> "END") THEN ' if country$ is END don't write
INPUT "What is the value of the coin? ", value$
INPUT "What is the name of the coin? ", coinName$
INPUT "What year was the coin minted? ", year%
WRITE #1, country$, value$, coinName$, year% ' send fields
END IF
PRINT ' print blank lines between coins
LOOP
CLOSE #1 ' close the file
' wait for the user to press Enter to continue
INPUT "Press Enter to see the contents of your coin collection", dummy$
CLS ' start with a fresh screen
' open file in INPUT mode so that contents can be read by program
OPEN "COINS.TXT" FOR INPUT AS #1 ' file is in current drive/dir
' display header for tabular collection information
PRINT "Coin origin Coin value Coin name Year minted"
PRINT "--------------------------------------------------------"
PRINT
' initialize formatting template for use with PRINT USING
tmp$ = "\ \ \ \ \ \ ####"
' while the end of the file has not been reached, assign file
' items to variables and print them out
DO WHILE (NOT EOF(1))
INPUT #1, country$, value$, coinName$, year%
PRINT USING tmp$; country$; value$; coinName$; year%
LOOP
CLOSE #1 ' close the file